package com.dragon.framework.config;

import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

/**
 * Web初始绑定配置
 *
 * @author dragon
 * @version 1.0
 * @date 2024/8/12 9:29
 */
@ControllerAdvice
public class WebInitBinderConfig {

    @InitBinder
    public void initBinder(@NonNull WebDataBinder binder) {
        // 去除表单请求参数前后空格
        binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    }

}
